package com.mine;

class Demo {
    public static boolean isInterleave(String s1, String s2, String s3) {
        int ai = 0;
        int bi = 0;
        for (int i = 0; i < s3.length(); i++) {
            char tmp = s3.charAt(i);
            if (s1.length() > ai && tmp == s1.charAt(ai)) {
                ai++;
            } else if (s2.length() > bi && tmp == s2.charAt(bi)) {
                bi++;
            } else {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        isInterleave("aabcc", "dbbca", "aadbbcbcac");
    }
}
